1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.FontChooserT; 26 27 public import glib.Str; 28 public import glib.c.functions; 29 public import gobject.ObjectG; 30 public import gobject.Signals; 31 public import gtk.c.functions; 32 public import gtk.c.types; 33 public import pango.PgFontDescription; 34 public import pango.PgFontFace; 35 public import pango.PgFontFamily; 36 public import pango.PgFontMap; 37 public import std.algorithm; 38 39 40 /** 41 * `GtkFontChooser` is an interface that can be implemented by widgets 42 * for choosing fonts. 43 * 44 * In GTK, the main objects that implement this interface are 45 * [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and 46 * [class@Gtk.FontButton]. 47 */ 48 public template FontChooserT(TStruct) 49 { 50 /** Get the main Gtk struct */ 51 public GtkFontChooser* getFontChooserStruct(bool transferOwnership = false) 52 { 53 if (transferOwnership) 54 ownedRef = false; 55 return cast(GtkFontChooser*)getStruct(); 56 } 57 58 59 /** 60 * Gets the currently-selected font name. 61 * 62 * Note that this can be a different string than what you set with 63 * [method@Gtk.FontChooser.set_font], as the font chooser widget may 64 * normalize font names and thus return a string with a different 65 * structure. For example, “Helvetica Italic Bold 12” could be 66 * normalized to “Helvetica Bold Italic 12”. 67 * 68 * Use [method@Pango.FontDescription.equal] if you want to compare two 69 * font descriptions. 70 * 71 * Returns: A string with the name 72 * of the current font 73 */ 74 public string getFont() 75 { 76 auto retStr = gtk_font_chooser_get_font(getFontChooserStruct()); 77 78 scope(exit) Str.freeString(retStr); 79 return Str.toString(retStr); 80 } 81 82 /** 83 * Gets the currently-selected font. 84 * 85 * Note that this can be a different string than what you set with 86 * [method@Gtk.FontChooser.set_font], as the font chooser widget may 87 * normalize font names and thus return a string with a different 88 * structure. For example, “Helvetica Italic Bold 12” could be 89 * normalized to “Helvetica Bold Italic 12”. 90 * 91 * Use [method@Pango.FontDescription.equal] if you want to compare two 92 * font descriptions. 93 * 94 * Returns: A `PangoFontDescription` for the 95 * current font 96 */ 97 public PgFontDescription getFontDesc() 98 { 99 auto __p = gtk_font_chooser_get_font_desc(getFontChooserStruct()); 100 101 if(__p is null) 102 { 103 return null; 104 } 105 106 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) __p, true); 107 } 108 109 /** 110 * Gets the `PangoFontFace` representing the selected font group 111 * details (i.e. family, slant, weight, width, etc). 112 * 113 * If the selected font is not installed, returns %NULL. 114 * 115 * Returns: A `PangoFontFace` representing the 116 * selected font group details 117 */ 118 public PgFontFace getFontFace() 119 { 120 auto __p = gtk_font_chooser_get_font_face(getFontChooserStruct()); 121 122 if(__p is null) 123 { 124 return null; 125 } 126 127 return ObjectG.getDObject!(PgFontFace)(cast(PangoFontFace*) __p); 128 } 129 130 /** 131 * Gets the `PangoFontFamily` representing the selected font family. 132 * 133 * Font families are a collection of font faces. 134 * 135 * If the selected font is not installed, returns %NULL. 136 * 137 * Returns: A `PangoFontFamily` representing the 138 * selected font family 139 */ 140 public PgFontFamily getFontFamily() 141 { 142 auto __p = gtk_font_chooser_get_font_family(getFontChooserStruct()); 143 144 if(__p is null) 145 { 146 return null; 147 } 148 149 return ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) __p); 150 } 151 152 /** 153 * Gets the currently-selected font features. 154 * 155 * Returns: the currently selected font features 156 */ 157 public string getFontFeatures() 158 { 159 auto retStr = gtk_font_chooser_get_font_features(getFontChooserStruct()); 160 161 scope(exit) Str.freeString(retStr); 162 return Str.toString(retStr); 163 } 164 165 /** 166 * Gets the custom font map of this font chooser widget, 167 * or %NULL if it does not have one. 168 * 169 * Returns: a `PangoFontMap` 170 */ 171 public override PgFontMap getFontMap() 172 { 173 auto __p = gtk_font_chooser_get_font_map(getFontChooserStruct()); 174 175 if(__p is null) 176 { 177 return null; 178 } 179 180 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) __p, true); 181 } 182 183 /** 184 * The selected font size. 185 * 186 * Returns: A n integer representing the selected font size, 187 * or -1 if no font size is selected. 188 */ 189 public int getFontSize() 190 { 191 return gtk_font_chooser_get_font_size(getFontChooserStruct()); 192 } 193 194 /** 195 * Gets the language that is used for font features. 196 * 197 * Returns: the currently selected language 198 */ 199 public string getLanguage() 200 { 201 auto retStr = gtk_font_chooser_get_language(getFontChooserStruct()); 202 203 scope(exit) Str.freeString(retStr); 204 return Str.toString(retStr); 205 } 206 207 /** 208 * Returns the current level of granularity for selecting fonts. 209 * 210 * Returns: the current granularity level 211 */ 212 public GtkFontChooserLevel getLevel() 213 { 214 return gtk_font_chooser_get_level(getFontChooserStruct()); 215 } 216 217 /** 218 * Gets the text displayed in the preview area. 219 * 220 * Returns: the text displayed in the preview area 221 */ 222 public string getPreviewText() 223 { 224 auto retStr = gtk_font_chooser_get_preview_text(getFontChooserStruct()); 225 226 scope(exit) Str.freeString(retStr); 227 return Str.toString(retStr); 228 } 229 230 /** 231 * Returns whether the preview entry is shown or not. 232 * 233 * Returns: %TRUE if the preview entry is shown or %FALSE if it is hidden. 234 */ 235 public bool getShowPreviewEntry() 236 { 237 return gtk_font_chooser_get_show_preview_entry(getFontChooserStruct()) != 0; 238 } 239 240 /** 241 * Adds a filter function that decides which fonts to display 242 * in the font chooser. 243 * 244 * Params: 245 * filter = a `GtkFontFilterFunc` 246 * userData = data to pass to @filter 247 * destroy = function to call to free @data when it is no longer needed 248 */ 249 public void setFilterFunc(GtkFontFilterFunc filter, void* userData, GDestroyNotify destroy) 250 { 251 gtk_font_chooser_set_filter_func(getFontChooserStruct(), filter, userData, destroy); 252 } 253 254 /** 255 * Sets the currently-selected font. 256 * 257 * Params: 258 * fontname = a font name like “Helvetica 12” or “Times Bold 18” 259 */ 260 public void setFont(string fontname) 261 { 262 gtk_font_chooser_set_font(getFontChooserStruct(), Str.toStringz(fontname)); 263 } 264 265 /** 266 * Sets the currently-selected font from @font_desc. 267 * 268 * Params: 269 * fontDesc = a `PangoFontDescription` 270 */ 271 public void setFontDesc(PgFontDescription fontDesc) 272 { 273 gtk_font_chooser_set_font_desc(getFontChooserStruct(), (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 274 } 275 276 /** 277 * Sets a custom font map to use for this font chooser widget. 278 * 279 * A custom font map can be used to present application-specific 280 * fonts instead of or in addition to the normal system fonts. 281 * 282 * ```c 283 * FcConfig *config; 284 * PangoFontMap *fontmap; 285 * 286 * config = FcInitLoadConfigAndFonts (); 287 * FcConfigAppFontAddFile (config, my_app_font_file); 288 * 289 * fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); 290 * pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config); 291 * 292 * gtk_font_chooser_set_font_map (font_chooser, fontmap); 293 * ``` 294 * 295 * Note that other GTK widgets will only be able to use the 296 * application-specific font if it is present in the font map they use: 297 * 298 * ```c 299 * context = gtk_widget_get_pango_context (label); 300 * pango_context_set_font_map (context, fontmap); 301 * ``` 302 * 303 * Params: 304 * fontmap = a `PangoFontMap` 305 */ 306 public override void setFontMap(PgFontMap fontmap) 307 { 308 gtk_font_chooser_set_font_map(getFontChooserStruct(), (fontmap is null) ? null : fontmap.getPgFontMapStruct()); 309 } 310 311 /** 312 * Sets the language to use for font features. 313 * 314 * Params: 315 * language = a language 316 */ 317 public void setLanguage(string language) 318 { 319 gtk_font_chooser_set_language(getFontChooserStruct(), Str.toStringz(language)); 320 } 321 322 /** 323 * Sets the desired level of granularity for selecting fonts. 324 * 325 * Params: 326 * level = the desired level of granularity 327 */ 328 public void setLevel(GtkFontChooserLevel level) 329 { 330 gtk_font_chooser_set_level(getFontChooserStruct(), level); 331 } 332 333 /** 334 * Sets the text displayed in the preview area. 335 * 336 * The @text is used to show how the selected font looks. 337 * 338 * Params: 339 * text = the text to display in the preview area 340 */ 341 public void setPreviewText(string text) 342 { 343 gtk_font_chooser_set_preview_text(getFontChooserStruct(), Str.toStringz(text)); 344 } 345 346 /** 347 * Shows or hides the editable preview entry. 348 * 349 * Params: 350 * showPreviewEntry = whether to show the editable preview entry or not 351 */ 352 public void setShowPreviewEntry(bool showPreviewEntry) 353 { 354 gtk_font_chooser_set_show_preview_entry(getFontChooserStruct(), showPreviewEntry); 355 } 356 357 /** 358 * Emitted when a font is activated. 359 * 360 * This usually happens when the user double clicks an item, 361 * or an item is selected and the user presses one of the keys 362 * Space, Shift+Space, Return or Enter. 363 * 364 * Params: 365 * fontname = the font name 366 */ 367 gulong addOnFontActivated(void delegate(string, FontChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 368 { 369 return Signals.connect(this, "font-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 370 } 371 }